import type { Addbuild, AddParkObj, BuildData, buildingRes, Datum, DaUploadFile, EnterpriseDetail, IndustryList, ParkData, ParkReu, RentData, RentFl } from "@/types/Park"
import service, { request } from "@/utils/reuqest"


export const ParkList=(date:ParkReu)=>{
    return request<ParkData>('/park/enterprise','get',date)
}
// 获取行业列表
export const Industry=()=>{
    return request<IndustryList[]>('/park/industry')
}
// 上传文件
export const UpLoadfile=(date:FormData)=>{
    return request<DaUploadFile>('/upload','post',date)
}

// 添加企业
export const AddPark=(date:AddParkObj)=>{
    return request('/park/enterprise','post',date)
}
// 查看企业详情
export const DetailPark=(id:string)=>{
    return request<AddParkObj>(`/park/enterprise/${id}`)
}
// 编辑

export const EditPark=(date:AddParkObj)=>{
    return request(`/park/enterprise`,'put',date)
}
// 删除
export const DelPark=(id:string)=>{
    return request(`/park/enterprise/${id}`,'DELETE')
}
// 获取可租赁楼宇
export const RentFloor=()=>{
    return request<RentFl[]>('/park/rent/building')
}
// 添加合同
export const AddRentOK=(date:RentData)=>{
    return request('/park/enterprise/rent','post',date)
}

// 获取合同列表
export const RentList=(id:number)=>{
    return request<Datum[]>(`/park/enterprise/rent/${id}`)
}
// 删除合同

export const DelRent=(id:number)=>{
    return request(`/park/enterprise/rent/${id}`,'delete')
}
// 园区管理-退租租赁合同
export const over=(id:number)=>{
    return request(`/park/enterprise/rent/${id}`,'put')
}
// 查看企业详情
/**
 * 获取企业详情
 * @param {*} id
 * @returns
 */
export const getEnterpriseDetailAPI = (id: string) => {
    return request<EnterpriseDetail>(`/park/enterprise/${id}`)
  }

/**
 * 合同下载
 * @param {*} id
 * @returns
 */
export const downloadContractAPI = (id: number) => {
    return service.request<null, Blob>({
        method: 'get',
        url:`/download/${id}`,
        responseType: 'blob'
    })
  }

//   楼宇查询
export const getBuildList = (data:buildingRes) => {
    return request<BuildData>('/park/building', 'GET', data)
  }
//   添加楼宇
export const addBuild = (data:Addbuild) => {
    return request('/park/building', 'POST', data)
  }